﻿'use strict';

// Shared scripting used in all other apps.
var context = SP.ClientContext.get_current();
var web = context.get_web();

var user = web.get_currentUser();
var viewModel;

// This code runs when the DOM is ready and creates a context object which is needed to use the SharePoint object model
// Wire up events.
$(document).ready(function () {

    // Load the user and onscusses create the viewmodel.
    context.load(user);
    context.executeQueryAsync(
        function (sender, args) {

            // Create the viewModel and initialize it.
            viewModel = new bucketListViewModel();
            viewModel.init();
        }, onFailedAction);
});

// This function is executed if the above call fails.
function onFailedAction(sender, args) {
    // Clear previously messages
    $('#message').empty();
    $('#message').text("Could not complete action: " + args.get_message());
}
